#include <iostream>
#include <string>

using namespace std;

class Fruit
{
public:
	virtual void GetFruit() = 0;
};

class Apple : public Fruit
{
public:
	void GetFruit()
	{
		cout << "????......" << endl;
	}
};

class Pear : public Fruit
{
public:
	void GetFruit()
	{
		cout << "????......" << endl;
	}
};

class Banana : public Fruit
{
public:
	void GetFruit()
	{
		cout << "????......" << endl;
	}
};

class Factory
{
public:
	Fruit *CreateFruit(string str)
	{
		Fruit *fruit = nullptr;
		if (str == "??")
			fruit = new Apple;
		if (str == "??")
			fruit = new Pear;
		if (str == "??")
			fruit = new Banana;

		return fruit;
	}
};

int main()
{
	Fruit *fruit = nullptr;
	Factory *factory = new Factory;

	fruit = factory->CreateFruit("??");
	fruit->GetFruit();
	delete fruit;

	fruit = factory->CreateFruit("??");
	fruit->GetFruit();
	delete fruit;

	fruit = factory->CreateFruit("??");
	fruit->GetFruit();
	delete fruit;

	delete factory;
	return 0;
}
